package com.spring.controller;

import com.spring.pojo.Book;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class BookController {
    @Resource(name = "jdbcTemplateOne")
    JdbcTemplate jdbcTemplateOne;
    @Resource(name = "jdbcTemplateTwo")
    JdbcTemplate jdbcTemplateTwo;
    @GetMapping("/books")
    public  void test(){
        List<Book> books1=jdbcTemplateOne.query(
                "select * from book",new BeanPropertyRowMapper<>(Book.class));
        List<Book> books2=jdbcTemplateTwo.query(
                "select * from book",new BeanPropertyRowMapper<>(Book.class));
        System.out.println(books1);
        System.out.println(books2);
    }
}
